home *** CD-ROM | disk | FTP | other *** search
/ GameStar 2004 April / Gamestar_61_2004-04_dvdb.iso / DVDStar / Editace / hltp.exe / {app} / Source Code / Zoners Half-Life Tools / common / winding.h < prev   
C/C++ Source or Header  |  2002-05-20  |  3KB  |  82 lines

  1. #ifndef WINDING_H__
  2. #define WINDING_H__
  3.  
  4. #if _MSC_VER >= 1000
  5. #pragma once
  6. #endif
  7.  
  8. #include "basictypes.h"
  9. #include "mathtypes.h"
  10. #include "win32fix.h"
  11. #include "mathlib.h"
  12. #include "bspfile.h"
  13. #include "boundingbox.h"
  14.  
  15. #define MAX_POINTS_ON_WINDING 128
  16. // TODO: FIX THIS STUPID SHIT (MAX_POINTS_ON_WINDING)
  17.  
  18. #define BASE_WINDING_DISTANCE 9000
  19.  
  20. #define    SIDE_FRONT        0
  21. #define    SIDE_ON            2
  22. #define    SIDE_BACK        1
  23. #define    SIDE_CROSS        -2
  24.  
  25. class Winding
  26. {
  27. public:
  28.     // General Functions
  29.     void            Print() const;
  30.     void            getPlane(dplane_t& plane) const;
  31.     void            getPlane(vec3_t& normal, vec_t& dist) const;
  32.     vec_t           getArea() const;
  33.     void            getBounds(BoundingBox& bounds) const;
  34.     void            getBounds(vec3_t& mins, vec3_t& maxs) const;
  35.     void            getCenter(vec3_t& center) const;
  36.     Winding*        Copy() const;
  37.     void            Check() const;  // Developer check for validity
  38.     bool            Valid() const;  // Runtime/user/normal check for validity
  39.     void            addPoint(const vec3_t newpoint);
  40.     void            insertPoint(const vec3_t newpoint, const unsigned int offset);
  41.  
  42.     // Specialized Functions
  43.     void            RemoveColinearPoints();
  44.     bool            Clip(const dplane_t& split, bool keepon); // For hlbsp
  45.     void            Clip(const dplane_t& split, Winding** front, Winding** back);
  46.     void            Clip(const vec3_t normal, const vec_t dist, Winding** front, Winding** back);
  47.     bool            Chop(const vec3_t normal, const vec_t dist);
  48.     void            Divide(const dplane_t& split, Winding** front, Winding** back);
  49.     int             WindingOnPlaneSide(const vec3_t normal, const vec_t dist);
  50.     void            CopyPoints(vec3_t *points, int &numpoints);
  51.  
  52.     void            initFromPoints(vec3_t *points, UINT32 numpoints);
  53.     void            Reset(void);    // Resets the structure
  54.  
  55. protected:
  56.     void            resize(UINT32 newsize);
  57.  
  58. public:
  59.     // Construction
  60.     Winding();                                        // Do nothing :)
  61.     Winding(vec3_t *points, UINT32 numpoints);        // Create from raw points
  62.     Winding(const dface_t& face);
  63.     Winding(const dplane_t& face);
  64.     Winding(const vec3_t normal, const vec_t dist);
  65.     Winding(UINT32 points);
  66.     Winding(const Winding& other);
  67.     virtual ~Winding();
  68.     Winding& operator=(const Winding& other);
  69.  
  70.     // Misc
  71. private:
  72.     void initFromPlane(const vec3_t normal, const vec_t dist);
  73.  
  74. public:
  75.     // Data
  76.     UINT32  m_NumPoints;
  77.     vec3_t* m_Points;
  78. protected:
  79.     UINT32  m_MaxPoints;
  80. };
  81.  
  82. #endif